package com.dm0858.bianmin.ui.presenter;

import com.dm0858.bianmin.model.response.ArticleDetailResponse;
import com.dm0858.bianmin.model.response.ArticleListResponse;
import com.dm0858.bianmin.ui.base.BasePresenter;
import com.dm0858.bianmin.view.IArticleDetailView;
import com.dm0858.bianmin.view.IArticleListView;
import com.socks.library.KLog;

import rx.Subscriber;

/**
 * Created by yelvqing on 2018/4/30.
 */

public class ArticleListPresenter extends BasePresenter<IArticleListView> {

    public ArticleListPresenter(IArticleListView view) {
        super(view);
    }

    public void getArticleList(String catid,String page) {
        addSubscription(mApiService.getArticleList(catid,page), new Subscriber<ArticleListResponse>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

                e.printStackTrace();
                KLog.e(e.getLocalizedMessage());
                mView.onError();
            }

            @Override
            public void onNext(ArticleListResponse response) {

                mView.onGetArticleList(response);
            }

        });
    }
}
